/**
 * @Date 2023-02-21 10:03:49
 * @Remark
 */

// react
import React from "react";
// lib
import { Button, Popconfirm, Space } from "antd";
// components & widget
// style
// config
// script & methods & public
// store
import { reportLost } from "./controller";
import { dictState } from "state/global";
// controller
// interface
// 其它

const TableColumns = [
  {
    title: "借阅Id",
    dataIndex: "id",
  },
  {
    title: "借阅人",
    dataIndex: "userId",
  },
  {
    title: "用户账号",
    dataIndex: "userName",
  },
  {
    title: "副本Id",
    dataIndex: "copyId",
  },

  {
    title: "书名",
    dataIndex: "title",
  },
  {
    title: "作者",
    dataIndex: "author",
  },
  {
    title: "出版社",
    dataIndex: "publisher",
  },
  {
    title: "ISBN",
    dataIndex: "isbn",
  },
  {
    title: "价格",
    dataIndex: "price",
  },
  {
    title: "借阅时间",
    dataIndex: "borrowDate",
  },
  {
    title: "应还时间",
    dataIndex: "dueDate",
  },
  {
    title: "归还时间",
    dataIndex: "returnDate",
  },
  {
    title: "状态",
    dataIndex: "status",
    render: (el: string) => dictState.BorrowStatusList.find(item => item.code === el)?.name
  },
  {
    title: "操作",
    key: "action",
    fixed: "right" as any,
    render: (el: any) => {
      // 丢失
      const lost = () => {
        reportLost(el.copyId)
      };
      return (
        <Space>
          {el.status === "BORROWED" && <Popconfirm title={"确定要将该图书报失吗？"} onConfirm={lost}>
            <Button size="small" type="primary" ghost>
              丢失
            </Button>
          </Popconfirm>}
        </Space>
      );
    },
  },
];

export default TableColumns;
